<template>
  <div class="icons">
    <swiper :options="swiperOption">
      <swiper-slide v-for="icons in page" :key="icons.index">
        <div class="icons-item" v-for="icon in icons">
          <img :src="icon.imgUrl" :alt="icon.title">
          <p>{{ icon.title }}</p>
        </div>
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>
<script>
  export default {
    props:['iconsList'],
    data(){
      return{
        swiperOption:{
          pagination: {
            el: '.swiper-pagination'
          },
          loop:true
        }
      }
    },
    mounted(){
      console.log(this.iconsList)
    },
    computed:{
      page(){
        let pages= [];
        this.iconsList.forEach((item,index)=>{
          let idx = Math.floor(index / 8);
          if(!pages[idx])pages[idx] = [];
          pages[idx].push(item);
        });
        return pages;
      }
    }
  }
</script>
<style scoped lang="stylus">
  @import "~css/common.styl"
  .icons{
    width: 100%;
    background-color: #fff;
  }
  .icons .icons-item{
    width: 25%;
    height: 0;
    padding-bottom:25%;
    float: left;
  }
  .icons img{
    width: 1.1rem;
    height: 1.1rem;
    display: block;
    margin: 0 auto;
    padding-top: .2rem;
  }
  .icons p{
    font-size: .28rem;
    text-align: center;
    margin-top: .1rem;
    textOverflow();
  }
  .icons .swiper-container-horizontal > .swiper-pagination-bullets {
    bottom: .1rem;
  }
  .icons .swiper-slide.swiper-slide-duplicate.swiper-slide-prev.swiper-slide-duplicate-next {
    height: 4.1rem;
  }
</style>
